<?php
namespace Api\Controller;
use Think\Controller\HproseController;

class CustomerController extends HproseController{
 
    public function add($data){
        
        $cid = M('Customer')->where(array('mobile'=>$data['mobile']))->getField('id');
        
        if($cid){
            return $cid;
        }
        else{
        
            $data['customer_name']=$data['mobile'];
            $data['level']=22;
            $data['source']=9;
			$data['last_service_time']=time();
            $customer_object = D('Customer');
            $data = $customer_object->create($data);
            return $customer_object->add();
        }
    }
    
    public function get_info($cid){
        if($cid){
            $info = M('Customer')->find($cid);
            $info['customer_service']=get_employee_info($info['customer_service_id'], 'name').','.get_employee_info($info['customer_service_id'], 'mobile');
            return $info;
        }
    }
}